package com.wangle.spring;

import com.wangle.spring.lifeCircle.User;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class test {

    /**
     * bean的实例话的四种方式
     * 1.构造方法实例化（xml配置）
     * 2.简单工厂实例化
     * @param args
     */
    public static void main(String[] args) {
        ClassPathXmlApplicationContext spring = new ClassPathXmlApplicationContext("spring.xml");
        //Object name = spring.getBean("name");
        //Object factory = spring.getBean("factory");
        //Object myBeanByFactoryBean = spring.getBean("myBeanByFactoryBean");
        User user = spring.getBean("user", User.class);
        ConfigurableListableBeanFactory beanFactory = spring.getBeanFactory();
        System.out.println(beanFactory.hashCode());
        System.out.println("第四步：使用bean");
        System.out.println(user.toString());
        spring.close();
        //System.out.println(myBeanByFactoryBean);
        
    }
}
